﻿package mortal.game.view.combinedServer.recharge
{
    import com.mui.controls.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.component.gconst.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.resource.*;
    import mortal.game.view.combinedServer.data.*;
    import mortal.game.view.common.*;
    import mortal.game.view.copy.GroupTowerCopy.data.*;
    import mortal.game.view.rebate.item.*;
    import mortal.game.view.signUp.sevenDayLogin.data.*;
    import mortal.mvc.core.*;

    public class CombinedSerRechargeCell extends GCellRenderer
    {
        protected var _mbg:GImageBitmap;
        protected var _titleDes:GImageBitmap;
        protected var _goldNum:GTextFiled;
        protected var _getBtn:GLoadingButton;
        protected var _list:CellsGridSprite;
        protected var _hasGetFlag:GImageBitmap;
        private var _info:Object;

        public function CombinedSerRechargeCell()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._mbg = UIFactory.gImageBitmap(ImagesConst.CombinedSerRechargeCellBg, 0, 0, this);
            this._titleDes = UIFactory.gImageBitmap(ImagesConst.CombinedSerRechargeCellTip, 10, 28, this);
            this._goldNum = UIFactory.gTextField("500", 137, 27, 65, 25, this, GlobalStyle.textFormatChen.setSize(16).center().setBold(true));
            this._getBtn = UIFactory.gLoadingButton(ImagesConst.RebateListGetBtn2_upSkin, 554, 16, 99, 43, this);
            this._getBtn.label = "";
            this._list = UIFactory.getUICompoment(CellsGridSprite);
            this._list.colNum = 6;
            this._list.vCellWid = 45;
            this._list.hCellWid = 45;
            this._list.genCellFun = this.genItem;
            this._list.genCells(6);
            this._list.x = 261;
            this._list.y = 19;
            this.addChild(this._list);
            this._hasGetFlag = UIFactory.gImageBitmap(ImagesConst.HasGetRewardFlag, 578, 19, this);
            this._hasGetFlag.visible = false;
            this._getBtn.configEventListener(MouseEvent.CLICK, this.onGetRw);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this.setBtn(false);
            this._mbg = null;
            this._titleDes = null;
            this._goldNum = null;
            this._getBtn = null;
            this._list = null;
            this._hasGetFlag = null;
            super.disposeImpl(param1);
            return;
        }// end function

        private function genItem() : RebateItem2
        {
            var _loc_1:* = UIFactory.getUICompoment(RebateItem2);
            return _loc_1;
        }// end function

        override public function set data(param1:Object) : void
        {
            this._info = param1;
            if (this._info == null)
            {
                return;
            }
            this._goldNum.text = "" + this._info.money;
            var _loc_2:* = this._info.giftCode;
            RewardCfgUtil.updateRwListByGiftCode(_loc_2, this._list);
            this.updateBtn(this._info.money);
            return;
        }// end function

        private function updateBtn(param1:int) : void
        {
            if (Cache.instance.combinedSer.rechargeInfo == null || Cache.instance.combinedSer.rechargeInfo.rewardInfo == null)
            {
                this.setBtn(false);
                return;
            }
            var _loc_2:* = Cache.instance.combinedSer.getRechrNum();
            var _loc_3:* = Cache.instance.combinedSer.rechargeInfo.rewardInfo[param1];
            this._hasGetFlag.visible = false;
            if (_loc_2 >= param1)
            {
                if (_loc_3 == 0)
                {
                    this.setBtn(true);
                }
                else
                {
                    this._hasGetFlag.visible = true;
                    this.setBtn(false);
                }
            }
            else
            {
                this.setBtn(false);
            }
            return;
        }// end function

        private function setBtn(param1:Boolean) : void
        {
            if (param1)
            {
                this._getBtn.enabled = true;
                this._getBtn.filters = null;
                SevenDayLoginUtil.showGuideArrow(this._getBtn, true, this);
            }
            else
            {
                SevenDayLoginUtil.showGuideArrow(this._getBtn, false, this);
                this._getBtn.enabled = false;
                this._getBtn.filters = [FilterConst.colorFilter2];
            }
            return;
        }// end function

        private function onGetRw(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(CombinedSerEvent.CombinedSerRechargeGetRw, this._info.money));
            return;
        }// end function

    }
}
